package com.boe.common.util.freemark.base;

import lombok.*;
import com.boe.common.util.freemark.BaseMethodModelFreemarker;
import com.google.common.base.Strings;
import freemarker.template.TemplateModelException;

import java.util.List;

public class FreemarkerHasValue extends BaseMethodModelFreemarker {


    @Override
    public Object exec(List list) throws TemplateModelException {

        Object paramValue  = getFreemarkerParameter(list.get(0));
        if (paramValue == null) {
            return false;
        }

        if (paramValue instanceof String) {
            return Strings.isNullOrEmpty((String) paramValue) == false;
        }

        return true;
    }
}
